package com.lingchou.cloud.process.api.controller;

import com.lingchou.cloud.process.api.dto.param.AddSignVo;
import com.lc.common.bean.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 流程操作API
 *
 * @author lc
 */
@RequestMapping(value = "process/v1")
@Api(value = "ProcessOperationApi", tags = "流程操作API")
public interface ProcessOperationApi {

    /**
     * 审批通过
     *
     * @param taskId 任务ID
     * @return 审批结果
     */
    @ApiOperation(value = "审批任务通过", notes = "审批任务通过")
    @GetMapping("/apply")
    Result<String> apply(@ApiParam(name = "taskId", value = "任务ID") @RequestParam String taskId,
                         @ApiParam(name = "operator", value = "操作人")@RequestParam String operator,
                         @ApiParam(name = "comment", value = "评论")@RequestParam(required = false) String comment);

    /**
     * 批量审批通过
     *
     * @param taskIds 任务ID
     * @return 审批结果
     */
    @ApiOperation(value = "批量任务审批通过", notes = "批量任务审批通过")
    @GetMapping("/applyForList")
    Result<String> applyForList(@ApiParam(name = "taskIds", value = "任务ID列表") @RequestParam List<String> taskIds,
                         @ApiParam(name = "operator", value = "操作人")@RequestParam String operator,
                         @ApiParam(name = "comment", value = "评论")@RequestParam(required = false) String comment);

    /**
     * 审批拒绝
     *
     * @param taskId 任务ID
     * @return 审批结果
     */
    @ApiOperation(value = "审批任务拒绝", notes = "审批任务拒绝")
    @GetMapping("/reject")
    Result<String> reject(@ApiParam(name = "taskId", value = "任务ID") @RequestParam String taskId,
                          @ApiParam(name = "operator", value = "操作人") @RequestParam String operator,
                          @ApiParam(name = "comment", value = "评论") @RequestParam(required = false) String comment);

    /**
     * 批量审批任务拒绝
     *
     * @param taskIds 任务ID列表
     * @return 审批结果
     */
    @ApiOperation(value = "批量审批任务拒绝", notes = "批量审批任务拒绝")
    @GetMapping("/rejectForList")
    Result<String> rejectForList(@ApiParam(name = "taskIds", value = "任务ID列表") @RequestParam List<String> taskIds,
                          @ApiParam(name = "operator", value = "操作人") @RequestParam String operator,
                          @ApiParam(name = "comment", value = "评论") @RequestParam(required = false) String comment);

    /**
     * 新增并签人
     *
     * @param taskActivityId    任务活动id
     * @param processInstanceId 任务所属流程实例ID
     * @param assignees         添加的人的列表
     * @return 操作结果
     */
    @ApiOperation(value = "新增并签人", notes = "在并签的节点上新增并签参与的人")
    @GetMapping("/addMultiInstanceExecution")
    Result<Object> addMultiInstanceExecution(@ApiParam(name = "taskActivityId", value = "任务活动id") @RequestParam String taskActivityId,
                                     @ApiParam(name = "processInstanceId", value = "任务所属流程实例ID") @RequestParam String processInstanceId,
                                     @ApiParam(name = "assignees", value = "添加的人的列表") @RequestParam List<String> assignees);


    /**
     * 委派任务
     *
     * @param taskId   任务ID
     * @param userId   受委派人
     * @param operator 操作人
     * @return 执行结果
     */
    @ApiOperation(value = "委派任务", notes = "委派任务（taskId）给委派人（userId）")
    @GetMapping("/delegateTask")
    Result<Object> delegateTask(@ApiParam(name = "taskId", value = "任务id") @RequestParam String taskId,
                        @ApiParam(name = "userId", value = "受委派人id") @RequestParam String userId,
                        @ApiParam(name = "operator", value = "操作人") @RequestParam String operator,
                        @ApiParam(name = "comment", value = "备注") @RequestParam String comment);

    /**
     * 转办任务
     *
     * @param taskId 任务ID
     * @param userId 受委派人
     * @return 执行结果
     */
    @ApiOperation(value = "转办任务", notes = "转办任务（taskId）给委派人（userId）")
    @GetMapping("/turnTask")
    Result<Object> turnTask(@ApiParam(name = "taskId", value = "任务id") @RequestParam String taskId,
                    @ApiParam(name = "userId", value = "转办人id") @RequestParam String userId,
                    @ApiParam(name = "operator", value = "操作人") @RequestParam String operator,
                    @ApiParam(name = "comment", value = "备注") @RequestParam String comment);

    /**
     * 删除流程实例
     *
     * @param processInstanceId 流程实例ID
     */
    @GetMapping(value = "/deleteProcessInstanceById")
    @ApiOperation(value = "删除流程实例", notes = "删除指定ID流程实例")
    Result<String> deleteProcessInstanceById(@RequestParam String processInstanceId);

    /**
     * 激活或者挂起流程实例
     *
     * @param processInstanceId 流程实例ID
     * @param suspension        是否暂停
     */
    @GetMapping(value = "/changeProcessInstanceStatusById")
    @ApiOperation(value = "激活或者挂起流程实例", notes = "激活或者挂起指定ID的流程实例")
    Result<String> changeProcessInstanceStatusById(@RequestParam String processInstanceId,
                                                   @RequestParam boolean suspension);

    /**
     * 终止流程
     *
     * @param processInstanceId 流程实例ID
     * @param comment           评论
     * @param operator          操作人
     */
    @GetMapping(value = "/stopProcessInstanceById")
    @ApiOperation(value = "终止流程", notes = "终止指定ID流程")
    Result<String> stopProcessInstance(@RequestParam String processInstanceId,
                                       @RequestParam String operator,
                                       @RequestParam String comment);

    /**
     * 任务加签
     *
     *
     * @param addSignVo 加签参数
     */
    @PostMapping("/addSign")
    @ApiOperation(value = "任务加签", notes = "任务加签,flag为true向后加签，为false向前加签")
    Result<String> addSignTask(@Validated @RequestBody AddSignVo addSignVo);
}
